package io.cw.service.impl.iml.background;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.cw.dao.background.ComplaintDao;
import io.cw.entity.background.ComplaintEntity;
import io.cw.entity.background.RoomEntity;
import io.cw.entity.reservation.ReservationEntity;
import io.cw.service.impl.background.ComplaintService;
import io.cw.service.impl.background.UserInfoService;
import io.cw.service.impl.reservation.ReservationRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Objects;


/**
 * 投诉记录服务类 服务类
 *
 * @author cw
 */
@Service
public class ComplaintServiceImpl extends ServiceImpl<ComplaintDao, ComplaintEntity> implements ComplaintService {

    @Autowired
    private UserInfoService userInfoService;

    @Autowired
    private ReservationRecordService reservationRecordService;


    @Override
    @Transactional
    public void add(ComplaintEntity dto) {
        dto.setId(IdWorker.getIdStr()).setProcessStatus(1).setIsValid(1);
        this.save(dto);
    }


    @Override
    public List<ComplaintEntity> findAll() {
        return this.lambdaQuery().eq(ComplaintEntity::getIsValid, 1)
                                 .orderByDesc(ComplaintEntity::getId)
                                 .list();
    }

    @Override
    public void handleComplaint(String id, Integer score) {
        // 获取投诉信息
        ComplaintEntity complaint = this.lambdaQuery().eq(ComplaintEntity::getId, id).one();
        if (Objects.isNull(complaint)) return;

        // 定位用户


        // 扣除积分
    }


}
